<?php

include_once( dirname(__FILE__).'/../basic/cfield.php' );

class CFCheckbox extends CField
{
#-------------------------------------------------------------------------------------------------------------------------
	var $is_checked = false;
	var $r_value 	= '';

#-------------------------------------------------------------------------------------------------------------------------

	function __set_params( &$params ){
		parent :: __set_params( $params );
		$this->is_checked 	= 	$params['checked'] ? true : false;
		$this->r_value 		=	$params['value'];
	}

#-------------------------------------------------------------------------------------------------------------------------

	function set_unique_vars( &$vars ){
		parent :: set_unique_vars( $vars );
		if ( $this->is_checked ){
			$vars['__checked_'.$this->name] = 1;
		}
		$vars['__value_'.$this->name] = $this->r_value;
	}

#-------------------------------------------------------------------------------------------------------------------------

	function set_value( $value ){
		if ( $this->value == $this->r_value ){
			$this->is_checked = true;
		}else{
			$this->is_checked = false;
			$value = '';
		}
		parent :: set_value( $value );
	}

#-------------------------------------------------------------------------------------------------------------------------

}

?>